package net.pws.oos.web;

import java.text.SimpleDateFormat;

import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;

public class CustomObjectMapper extends ObjectMapper {

    public static final SimpleDateFormat shortFormatter = new SimpleDateFormat("yyyy-MM-dd");

    public static final SimpleDateFormat longFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    
    public CustomObjectMapper() {
        //registerModule(new HibernateModule());
        configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS,
                  false);
        configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
        configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
        getSerializationConfig().withDateFormat(longFormatter);
        getDeserializationConfig().withDateFormat(longFormatter);
        setDateFormat(longFormatter);
    }
    
    public void setPrettyPrint(boolean prettyPrint) {
        configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyPrint);
    }
    
}
